package com.xiang.consumer;

import com.rabbitmq.client.Channel;
import com.xiang.config.RabbitMqTopicConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 消费者
 *
 * @author: xiangtianlei
 * @Date: 2022-9-2
 */
@Component
public class ConsumerTopics {
    Logger log = LoggerFactory.getLogger(ConsumerTopics.class);

    /**
     * 监听email队列
     *
     * @param obj, message, channel
     * @return void
     */
    @RabbitListener(queues = {RabbitMqTopicConfig.QUEUE_INFORM_EMAIL})
    public void monitorEmailQueue(Object obj, Message message, Channel channel) {
        log.info("email队列消息体:" + new String(message.getBody()));
    }

    /**
     * 监听sms队列
     *
     * @param obj, message, channel
     * @return void
     */
    @RabbitListener(queues = {RabbitMqTopicConfig.QUEUE_INFORM_SMS})
    public void monitorSmsQueue(Object obj, Message message, Channel channel) {
        log.info("sms队列消息体:" + new String(message.getBody()));
    }
}
